/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package e.odbo.data.impexp.model;

import e.odbo.data.dao.table.I_TableSentenceBuilder;
import e.odbo.data.impexp.FieldGenerator;
import e.odbo.data.dao.table.TableDefinition;


/**
 * @author Administrator
 */
public class ImpExpTableDefinition extends AbstractImpExpTableDefinition {

    public ImpExpTableDefinition(TableDefinition baseTable, I_TableSentenceBuilder tableSentenceBuilder) {
        super(baseTable, tableSentenceBuilder);
    }

    public Object[] getData(int rowIndex) {
        ImpExpRowDefinition row = getRow(rowIndex);
        Object[] rowdata = row.getDatas();
        if (row.getState() == ImpExpRowDefinition.STATE_Import_Insert) {
            for (int i = 0; i < getFieldIndexs().length; i++) {
                if (fieldGenerators.containsKey(i)) {
                    FieldGenerator generator = fieldGenerators.get(i);
                    rowdata[i] = generator.getNext();
                }
            }
        }
        return rowdata;
    }

    public int[] getFieldIndexs() {
        return filterIndexs;
    }

    public int[] getUpdateFieldIndexs() {
        return filterIndexs;
        /**List<Integer> s1 = new ArrayList<Integer>();
         List<Integer> s2 = new ArrayList<Integer>();
         for (int i = 0; i < filterIndexs.length; i++) {
         s1.addData(filterIndexs[i]);
         }
         for (int i = 0; i < updateIgnoreIndexs.length; i++) {
         s2.addData(updateIgnoreIndexs[i]);
         }
         s1.removeAll(s2);
         int[] updateIndexs = new int[s1.size()];
         for (int i = 0; i < s1.size(); i++) {
         updateIndexs[i] = s1.get(i).intValue();
         }
         return updateIndexs;*/
    }


    public void setFieldIndexs(int[] inds) {
        filterIndexs = inds;
    }
}
